/**
 * 
 */
package org.mspring.crm.service.impl;

import java.util.List;

import org.apache.log4j.Logger;
import org.mspring.crm.dao.permission.ResourceDao;
import org.mspring.crm.entity.permission.Resource;
import org.mspring.crm.service.ResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Gao Youbo
 * @since Feb 20, 2012
 */
@Service
@Transactional
public class ResourceServiceImpl implements ResourceService {

    private static final Logger log = Logger.getLogger(ResourceServiceImpl.class);

    private ResourceDao resourceDao;

    @Autowired
    public void setResourceDao(ResourceDao resourceDao) {
        this.resourceDao = resourceDao;
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.mspring.crm.service.ResourceService#findResourcesByAuthName(java.lang.String)
     */
    public List<Resource> findResourcesByAuthName(String authName) {
        // TODO Auto-generated method stub
//        StringBuffer queryString = new StringBuffer();
//        queryString.append("select res from Resource res, AuthorityResource authRes ");
//        queryString.append("where res.id = authRes.resource.id ");
//        queryString.append("and res.enabled = true ");
//        queryString.append("and authRes.authority.enabled = true ");
//        queryString.append("and authRes.authority.name = ? ");
//        return resourceDao.find(queryString.toString(), authName);
        return resourceDao.findAll();
    }

}
